Skip to content

Add context compression: compact memory, duplicate prevention, inline context#13

Open
CMander02 wants to merge 1 commit intoziyan-todo-3from
ziyan-todo-4
Open

Add context compression: compact memory, duplicate prevention, inline context#13
CMander02 wants to merge 1 commit intoziyan-todo-3from
ziyan-todo-4

Conversation

@CMander02
Copy link
Copy Markdown
Collaborator

Summary

  • Add render_compact_stage_entry with _truncate_section for budget-controlled memory entries
  • append_approved_stage_summary uses compact entries and prevents duplicate stage headings
  • build_continuation_prompt inlines user goal, current objective, and recent stage summaries
  • Continuation prompts now have enough context for session fallback to fresh sessions

Context

Example run showed prompt growing from 8KB (Stage 01) to 75KB (Stage 08) — 9.5x inflation. memory.md reached 820 lines / 74KB with duplicate content. Continuation prompts had 7x less information than initial prompts.

Depends on #12.

Test plan

  • 13 new tests in tests/test_context_compression.py — all passing
  • Verify compact memory is >30% smaller than full memory for 6+ stages

🤖 Generated with Claude Code

…, inline context

- Add render_compact_stage_entry with _truncate_section for budget-controlled summaries
- append_approved_stage_summary now uses compact entries and prevents duplicate stage headings
- build_continuation_prompt inlines user goal, current objective, and recent stage summaries
- Continuation prompts now have enough context for session fallback to fresh sessions
- 13 new tests covering truncation, dedup, inline context, and size reduction

Addresses TODO 4 (V4-1 through V4-4) from vulnerability analysis.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant